home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 …ember: Reference Library / Apple Developer Reference Library (December 1999) (Disk 1).iso / pc / technical documentation / develop / develop issue 20 / develop issue 20 code / scripting the finder.sea / Scripting the Finder / Zawphing / StringUtilities.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-11  |  2.7 KB  |  80 lines  |  [TEXT/MMCC]

  1. /*================================================================================
  2.     stringUtilities.h
  3.     
  4.     ©1991-2 Greg Anderson
  5.     greggor@apple.com
  6.         
  7.     This .h file provides macros for scanning through strings.
  8.     It is assumed that all strings being scanned are null-terminated
  9.         
  10. ================================================================================*/
  11. #ifndef __STRINGUTILITIES__
  12. #define __STRINGUTILITIES__
  13.  
  14. #ifndef __TYPES__
  15. #include <Types.h>
  16. #endif
  17.  
  18. #define IsDigit(c)            ( ((c) >= '0') && ((c) <= '9') )
  19. #define IsNumeric(c)        ( IsDigit(c) || ((c) == '-') )
  20. #define IsAlpha(c)            ( ( ((c) >= 'A') && ((c) <= 'Z') ) || ( ((c) >= 'a') && ((c) <= 'z') ) )
  21. #define IsAlphaNumeric(c)    ( IsNumeric(c) || IsAlpha(c) )
  22. #define IsWhiteSpace(c)        ( (c) <= ' ' )
  23.  
  24. /*
  25. // Macros:
  26. //
  27. // ToUpper(c)
  28. //
  29. //        Convert 'c' to an uppercase character if it is a lowercase character
  30. //
  31. // SkipToWhiteSpace(p)
  32. //
  33. //        Skip to the next whitespace character (or null)
  34. //
  35. // SkipPastWhitespace(p)
  36. //
  37. //        Skip to the next non-whitespace character (or null)
  38. //
  39. // SkipToSpec(p,spec)
  40. //
  41. //        Skip to the next occurance of the specified character (or null)
  42. //
  43. // SkipToDigit(p)
  44. //
  45. //        Skip to the next numeric digit (or null)
  46. //
  47. // SkipToNextLine(p)
  48. //
  49. //        Like it says:  skip to the beginning of the next line
  50. */
  51. #define ToUpper(c) ( ((c >= 'a') && (c <= 'z')) ? c - 'a' + 'A' : c )
  52. #define SkipToWhitespace( line ) while( *(line) > ' ' ) (line)++
  53. #define SkipPastWhitespace( line ) while( (*(line) <= ' ') && (*(line) != '\r') && (*(line)) ) (line)++
  54. #define SkipToSpec( line, spec ) while( (*(line) != spec) && (*(line)) ) (line)++
  55. #define SkipToDigit( line ) while( ((*(line) < '0') || (*(line) > '9')) && (*(line)) ) (line)++
  56. #define SkipToNextLine( line ) do{ SkipToSpec(line, '\r'); while( (*(line) < ' ') && (*(line)) ) (line)++; } while(false)
  57.  
  58. /*
  59. // Prototypes for stringUtilities.c
  60. */
  61. void                PtoCcpy( char* cstr, Str255 pstr );
  62. void                CtoPcpy(  Str255 pstr, char* cstr );
  63. short                PtoCcmp( Str255 pstr, char* cstr );
  64. pascal void            pstrcpy( Str255 dest, Str255 src );
  65. pascal void            pstrcat( Str255 dest, Str255 src );
  66. short                pstrcmp( unsigned char* a, unsigned char* b );
  67. short                partialstrcmp( register char* s1, register char* s2);
  68. short                ScanNumberInString( char** line );
  69. short                NumberInString( char* line );
  70. void                ScanTextInString( char** line, Str255 pstr, Boolean terminateAtSpace );
  71. void                ScanWordInString( char** line, Str255 pstr );
  72. void                ScanLineInString( char** line, Str255 pstr );
  73.  
  74. void                AddHexCharToString( char* where, unsigned short hexNumber );
  75. void                AddHexByteToString( char* where, unsigned short hexNumber );
  76. void                AddHexShortToString( char* where, unsigned short hexNumber );
  77. void                AddHexLongToString( char* where, unsigned long hexNumber );
  78.  
  79. #endif
  80.